package com.ipfsemc.ipfsemc.controller.v1;

import com.ipfsemc.ipfsemc.model.TreeNode;
import com.ipfsemc.ipfsemc.service.ITreeNodeService;
import com.ipfsemc.ipfsemc.util.RespList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/tree")
public class TreeNodeController {
    @Autowired
    private ITreeNodeService treeNodeService;

    @RequestMapping("/listAll")
    @ResponseBody
    public RespList<TreeNode> listAll(TreeNode treeNode){
        List<TreeNode> treeNodes = treeNodeService.listParent(treeNode);
        RespList jsonData=new RespList();
        jsonData.setCode(0);
        jsonData.setMessage("成功！");
        jsonData.setResult(treeNodes);
        return jsonData;
    }

}